<?
/************************************************************************/
/* 	The author of this program code:                                    */
/*  Dmitry Sheiko (sheiko@cmsdevelopment.com)	                    	*/
/* 	Copyright by Dmitry Sheiko											*/
/* 	http://www.cmsdevelopment.com     									*/
/************************************************************************/

/**
	* @return void
	* @param string $root
	* @param string $addparams
	* @desc SOAP Call
	**/


function soap_call(){
	global $root_path, $http_path, $env, $sapi_obj;
	
	if(!$sapi_obj->env["this.param.ServerUrl"] OR !is_string($sapi_obj->env["this.param.ServerUrl"])) $sapi_obj->error = 'ServerUrl DDC parameter is invalid';
	require_once($root_path . 'SOAP/lib/nusoap.php');
	// Creating client instance...
	$client = new soapclient($sapi_obj->env["this.param.ServerUrl"], true);
	$err = $client->getError();
	if ($err) $sapi_obj->error = 'Error creating client instance: ' . $err . '';
	eval('$params = array('.$sapi_obj->env["this.param.params"].');');
	$result = $client->call($sapi_obj->env["this.param.call"], $params, "", $sapi_obj->env["this.param.ns"] );
	
	if(!$result) return false;
	if(is_array($result)) {
		if( is_array(each($result)) ) return $result;
	}
	if( is_string($result)) return array( 0 => array("result"=>$result));
	if( is_array($result)) return array( 0 => $result);
	
	return $result;
}

?>